﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BE;

namespace UI
{
    public partial class ContentWrapper : System.Web.UI.MasterPage
    {
		protected string TopBottom = "alignCartTop";
        protected void Page_Load(object sender, EventArgs e)
        {
			if(!IsPostBack)
			UpdateCart();
			DataBind();
        }

        

        public void UpdateCart()
        {
			Label lbl = new Label();
			lbl.Text = "";
			if ( ShoppingCart.Instance.Cart.Count == 0 )
			{
				lbl.Text = "your shopping cart is currently empty<br />";
				TopBottom = "alignCartBottom";
			}
			else
			{
				decimal price = 0;
				lbl.Text += "<h4> Current <a href=\"Cart.aspx\">Cart</a> Content:</h4><br />";
				foreach ( Album album in ShoppingCart.Instance.Cart )
				{
					lbl.Text += album.Artist + " - " + album.Title + "<br />";
					price += album.Price;
				}
				lbl.Text += "<br />Album(s): " + ShoppingCart.Instance.Cart.Count + "<br />Total Price: " + price.ToString( "F" ) + "<br />Proceed to <a href=\"Checkout.aspx\">checkout</a><br /><br />";
			
			}
			phCart.Controls.Add( lbl );
        }
    }
}